package com.atguigu.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;  
  
@RestController

// 加这个注解，读取 Nacos 配置才能生效
@RefreshScope
public class PaymentController{

    // atguigu.config.content 在本地配置文件中没有，这是要从 Nacos 服务器上读取
    @Value("${atguigu.config.content}")
    private String configContent;

    @Value("${server.port}")  
    private String serverPort;  
  
    @GetMapping(value = "/payment/nacos/{id}")  
    public String getPayment(@PathVariable("id") Long id) {  
        return "nacos registry, serverPort: "+ serverPort+"\t id"+id + " configContent = " + configContent;
    }  
}